﻿<%@ Page Title="" Language="C#" MasterPageFile="~/masterpage_user.master" AutoEventWireup="true"
    CodeFile="QLSanPham.aspx.cs" Inherits="QLSanPham" %>
<asp:Content ID="Content1" ContentPlaceHolderID="user_content" runat="Server">
    <script src="./javascripts/t_js.js"></script>
    <div id="quanlysanpham">
        <div class="title">Quản Lý Sản Phẩm</div>

        <div class="rowFeature">
            <div class="featureDeleteSelect">
                <asp:Button ID="btThemMoi" runat="server" Text="Thêm" 
                    onclick="btThemMoi_Click" />
                &nbsp;<asp:Button ID="btXoaChon" runat="server" onclick="btXoaChon_Click" 
                Text="Xóa" OnClientClick="return DeleteConfirmation();" /></div>
            <div class="featureSearch"><asp:TextBox ID="txtKeyword" runat="server"></asp:TextBox>&nbsp;&nbsp;
            <asp:Button ID="btTimKiem" runat="server" onclick="btTimKiem_Click" Text="Tìm kiếm" /></div>
        </div>

        <div class="messageError">
            <asp:Label ID="lblError" runat="server" Font-Bold="False" Font-Names="Arial" 
                Font-Size="X-Large" ForeColor="#CC0000" Visible="False"></asp:Label>
        </div>
    
        <div class="scrollGridView">
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
            DataKeyNames="Masanpham" DataSourceID="SqlDataSource1" Font-Names="Arial" Font-Overline="False"
            Font-Size="Medium" Font-Strikeout="False" 
                AllowPaging="True" AllowSorting="True" EmptyDataText="(Không tìm thấy dữ liệu!)"
            OnSelectedIndexChanged="GridView1_SelectedIndexChanged" 
                HorizontalAlign="Center" CssClass="table-a">
            <Columns>
                <asp:TemplateField>
                    <HeaderTemplate>
                        <asp:CheckBox ID="chkHeader" runat="server" AutoPostBack="true" OnCheckedChanged="chkHeader_CheckedChanged" />
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="chkItem" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Mã Sản Phẩm" SortExpression="Masanpham">
                    <ItemTemplate>
                        <asp:Label ID="Label3" runat="server" Text='<%# Bind("Masanpham") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Tên Sản Phẩm" SortExpression="Tensanpham">
                    <ItemTemplate>
                        <asp:Label ID="Label4" runat="server" Text=''></asp:Label>
                        <itemtemplate><%# HighlightText(txtKeyword.Text, Eval("Tensanpham").ToString()) %></itemtemplate>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Loại Sản Phẩm" SortExpression="loaisanpham">
                    <ItemTemplate>
                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("loaisanpham") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Giá" SortExpression="giasanpham">
                    <ItemTemplate>
                        <asp:Label ID="Label5" runat="server" Text='<%# Bind("giasanpham") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Mã Shop" SortExpression="Mashop" Visible="False">
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("Mashop") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <EditItemTemplate>
                        &nbsp;
                    </EditItemTemplate>
                    <ItemTemplate>
                        <input type="button" onclick="location.href='editQLSanPham.aspx?MaSP=<%#Eval("Masanpham")%>'" value="Sửa" />
                        &nbsp;<asp:Button ID="Button2" runat="server" CausesValidation="False" CommandName="Delete" OnClientClick="return DeleteConfirmation();"
                            Text="Xóa" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
                <EmptyDataRowStyle HorizontalAlign="Center" Font-Size="X-Large" ForeColor="#CC0000" />
            <FooterStyle 
                    HorizontalAlign="Center" />
            <HeaderStyle Font-Underline="True"
                Height="30px" HorizontalAlign="Center" VerticalAlign="Middle" />
            <PagerSettings PageButtonCount="7" />
            <PagerStyle CssClass="page" Font-Names="Arial" 
                    Font-Size="Large" 
                    VerticalAlign="Middle" />
            <RowStyle HorizontalAlign="Center" />
        </asp:GridView>
        </div>
    </div>

        <asp:Label ID="Label5" runat="server" Text="Label" Visible="False"></asp:Label>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:chodientuConnectionString %>"
        
        SelectCommand="sp_DSSanPham" OldValuesParameterFormatString="original_{0}"
        DeleteCommand="DELETE FROM [Sanpham] WHERE [Masanpham] = @original_Masanpham"
        InsertCommand="INSERT INTO [Sanpham] ([Masanpham], [Mashop], [Tensanpham], [loaisanpham]) VALUES (@Masanpham, @Mashop, @Tensanpham, @loaisanpham)"
        
        
        UpdateCommand="UPDATE [Sanpham] SET [Mashop] = @Mashop, [Tensanpham] = @Tensanpham, [loaisanpham] = @loaisanpham WHERE [Masanpham] = @original_Masanpham" 
        SelectCommandType="StoredProcedure" onselecting="SqlDataSource1_Selecting">
        <DeleteParameters>
            <asp:Parameter Name="original_Masanpham" Type="String" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="Masanpham" Type="String" />
            <asp:Parameter Name="Mashop" Type="String" />
            <asp:Parameter Name="Tensanpham" Type="String" />
            <asp:Parameter Name="loaisanpham" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="txtKeyword" ConvertEmptyStringToNull="False" 
                Name="TenSP" PropertyName="Text" Type="String" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="Mashop" Type="String" />
            <asp:Parameter Name="Tensanpham" Type="String" />
            <asp:Parameter Name="loaisanpham" Type="String" />
            <asp:Parameter Name="original_Masanpham" Type="String" />
        </UpdateParameters>
    </asp:SqlDataSource>
    </asp:Content>

